package cn.zs.supply.service.imp;


//import com.github.pagehelper.Page;
//import com.github.pagehelper.PageHelper;
import cn.zs.supply.common.core.domain.result.PageResult;
import cn.zs.supply.common.core.service.BaseService;
import cn.zs.supply.dao.UserMapper;
import cn.zs.supply.domain.dto.UserDto;

import cn.zs.supply.domain.po.UserTest;
import cn.zs.supply.domain.query.UserQuery;
import cn.zs.supply.domain.vo.UserVo;
import cn.zs.supply.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;


@Service
@Slf4j
public class TestServiceImpl extends BaseService implements TestService {
    @Resource
    private UserMapper userMapper;

    public UserVo getUser(Long userId) {
        List<UserTest> s= userMapper.selectAll();
        UserTest user = userMapper.selectByPrimaryKey(userId);
        UserVo userVo = new UserVo();
        if (user == null) {
            return null;
        }
        BeanUtils.copyProperties(user, userVo);
        return userVo;
    }
    public PageResult<UserVo> getUserList(UserQuery query) {
        List<UserTest>  userList=userMapper.selectAll();

        /**
        Page<User> page = PageHelper.startPage(query.getPageNo(), query.getPageSize());
        List<User> userList = userMapper.queryUserList(query.getUserName());
        List<UserVo> userVos = new ArrayList<>();
        for (User user : userList) {
            UserVo vo = new UserVo();
            BeanUtils.copyProperties(user, vo);
            userVos.add(vo);
        }
        return ResultBuilder.genSuccessPageResult(userVos, page.getTotal(), page.getPageSize(), page.getPageNum());
        **/
        return null;
    }

    public void addUser(UserDto dto) {
        UserTest user = new UserTest();
        BeanUtils.copyProperties(dto, user);
        //user.setUserId(12345);
        userMapper.insert(user);
    }

}
